package com.goodving.guli.activity;

import android.app.Activity;
import android.content.Intent;
import android.graphics.Rect;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.TouchDelegate;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.TextView;

import com.goodving.guli.R;
import com.goodving.guli.bt.C0668a;
import com.goodving.guli.view.DeviceListFragment;

/**
 * Created by john on 2015/11/24.
 */
public class GuliHardwareSettingActivity extends SystemBarTintActivity implements OnClickListener {
    public static final String f9247a = "select_device";
    private boolean f9248b;

    public void GuliHardwareSettingActivity() {
        this.f9248b = false;
    }

    public void m14066a() {
    }

    public void m14067b() {
    }

    public void onClick(View view) {
        if (view.getId() == R.id.skip_bind) {
            finish();
        }
    }

    class dP implements Runnable
    {

        final View a;
        final View b;
        final GuliHardwareSettingActivity thisGuliHardwareSettingActivity;

        dP(GuliHardwareSettingActivity settingactivity, View view, View view1)
        {
            super();
            thisGuliHardwareSettingActivity = settingactivity;
            a = view;
            b = view1;
        }

        public void run()
        {
            Rect rect = new Rect();
            a.getHitRect(rect);
            rect.left = rect.left - 200;
            rect.top = rect.top - 200;
            rect.right = rect.right + 200;
            rect.bottom = rect.bottom + 200;
            b.setTouchDelegate(new TouchDelegate(rect, a));
        }
    }
    protected void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        setContentView((int) R.layout.activity_settings);
        DeviceListFragment deviceListFragment = (DeviceListFragment) getFragmentManager().findFragmentById(R.id.content);
        Intent intent = getIntent();
        if (intent != null) {
            this.f9248b = intent.getBooleanExtra(f9247a, false);
            if (this.f9248b) {
                deviceListFragment.m13758a(2);
                ((TextView) findViewById(R.id.title)).setText(getResources().getString(R.string.select_devices));
                View findViewById = findViewById(R.id.settings_parent);
                View findViewById2 = findViewById(R.id.skip_bind);
                findViewById.post(new dP(this, findViewById2, findViewById));
                findViewById2.setVisibility(View.VISIBLE);
                findViewById2.setOnClickListener(this);
                findViewById(R.id.home_back).setVisibility(View.INVISIBLE);
            }
        }
//        if (!DeviceSource.hasBindBracelet() && DeviceSource.hasBindWeight()) {
//            C0668a.m8128a((Context) this, C0668a.fJ, "01");
//        } else if (DeviceSource.hasBindBracelet() && DeviceSource.hasBindWeight()) {
//            C0668a.m8128a((Context) this, C0668a.fJ, Constants.VIA_REPORT_TYPE_SHARE_TO_QZONE);
//        }
    }

    public boolean onKeyDown(int i, KeyEvent keyEvent) {
        return super.onKeyDown(i, keyEvent);
    }

    protected void onPause() {
        super.onPause();
        C0668a.m8138b((Activity) this);
    }

    protected void onResume() {
        super.onResume();
        C0668a.m8124a((Activity) this);
    }
}

